"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const express_1 = __importDefault(require("express"));
const cors_1 = __importDefault(require("cors"));
const dotenv_1 = __importDefault(require("dotenv"));
const database_1 = require("./config/database");
const auth_1 = __importDefault(require("./routes/auth"));
const notes_1 = __importDefault(require("./routes/notes"));
const upload_1 = __importDefault(require("./routes/upload"));
const errorHandler_1 = require("./middleware/errorHandler");
dotenv_1.default.config();
const app = (0, express_1.default)();
const PORT = process.env.PORT || 3000;
// 中间件
app.use((0, cors_1.default)());
app.use(express_1.default.json({ limit: '10mb' }));
app.use(express_1.default.urlencoded({ extended: true }));
// 数据库连接
(0, database_1.connectDB)();
// 路由
app.use('/api/auth', auth_1.default);
app.use('/api/notes', notes_1.default);
app.use('/api/upload', upload_1.default);
// 错误处理中间件
app.use(errorHandler_1.errorHandler);
// 健康检查
app.get('/health', (req, res) => {
    res.json({ status: 'OK', message: 'Web Notes API is running' });
});
app.listen(PORT, () => {
    console.log(`🚀 服务器运行在端口 ${PORT}`);
});
